package com.gao.masterslave.controller;

import com.gao.masterslave.common.Result;
import com.gao.masterslave.common.req.OrderReq;
import com.gao.masterslave.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单请求
 */
@RestController
public class OrderController {

    @Autowired
    @Qualifier(value = "OrderServiceImpl")
    private OrderService orderService;

    @Autowired
    @Qualifier(value = "orderRedissonImpl")
    private OrderService orderRedisson;

    /**
     * 订单创建
     * @param orderReq
     * @return
     */
    @PostMapping("order")
    public Result createOrder(OrderReq orderReq) {
        return orderService.doProcess(orderReq);
    }

    /**
     * 订单创建 Redisson 实现
     * @param orderReq
     * @return
     */
    @PostMapping("order1")
    public Result createOrderByRedisson(OrderReq orderReq) {
        return orderRedisson.doProcess(orderReq);
    }
}
